package com.sctvcloud.longchang.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseAbstractAdapter;
import com.sctvcloud.longchang.R;
import com.sctvcloud.longchang.beans.NewsItem;
import com.sctvcloud.longchang.ui.adapter.holder.GridCankaoHolder;
import com.sctvcloud.longchang.ui.utils.GlideCircleTransform;
import com.sctvcloud.longchang.ui.utils.GlideUtil;

import java.util.List;


/**
 * Created by Ly on 2016/10/27.
 */
public class GrideCankaoAdapter extends BaseAbstractAdapter<NewsItem> {



    private GlideCircleTransform circleTransform;


    public GrideCankaoAdapter(Context context, List<NewsItem> datas) {
        super(context, datas);
    }

    public GrideCankaoAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        GridCankaoHolder sh=null;
        if(view==null){
            view= LayoutInflater.from(context).inflate(R.layout.item_subscription_cankao, viewGroup, false);
            sh=new GridCankaoHolder(view);
        }else{
            sh= (GridCankaoHolder) view.getTag();
        }
        NewsItem si=datas.get(i);

        circleTransform = new GlideCircleTransform(context);
        sh.name.setText(si.getNewsTitle());

        GlideUtil.getGlid(context, si.getNewsImage()).into(sh.img);


        return view;
    }
}
